//
//  LayoutBehavior.swift
//  SwiftUIDemo
//
//  Created by zhouzuosong on 2020/8/16.
//  Copyright © 2020 Kael. All rights reserved.
//

import SwiftUI

struct LayoutBehavior: View {
    var body: some View {
        VStack(spacing: 20) {
            Text("约束习惯").font(.title)
            Text("Pull in 往里拉").foregroundColor(.gray)
            Text("有些视图的大小是他们容纳文本的最小尺寸 （这里只说高度）")
                .frame(maxWidth: .infinity)
                .padding()
                .background(Color.purple)
                .foregroundColor(Color.white)
                .layoutPriority(1)
            Image(systemName: "arrow.down.to.line.alt")
            HStack(spacing: 30){
                Image(systemName: "arrow.right.to.line.alt")
                Text("Text View 被压缩进去")
                Image(systemName: "arrow.left.to.line.alt")
            }
            Image(systemName: "arrow.up.to.line.alt")

            Text("Text View 看似被压缩进去了）")
                .frame(maxWidth: .infinity)
                .padding()
                .background(Color.purple)
                .foregroundColor(Color.white)
                .layoutPriority(1)
            
            Color.red
                .overlay(
                    Image(systemName: "arrow.up.left")
                        .padding()
                    ,alignment: .topLeading

                )
                .overlay(
                    Image(systemName: "arrow.up.right")
                        .padding()
                    ,alignment: .topTrailing

                )
                .overlay(
                    Image(systemName: "arrow.down.left")
                        .padding()
                    ,alignment: .bottomLeading

                )
                .overlay(
                    Image(systemName: "arrow.down.right")
                        .padding()
                    ,alignment: .bottomTrailing

                )
                .overlay(
                    Text("往视图里面添加视图")
//                        .foregroundColor(.white)
                )
//                .foregroundColor(.white)
                
        }
    }
}

struct LayoutBehavior_Previews: PreviewProvider {
    static var previews: some View {
        LayoutBehavior()
//        LayoutBehavior()
//            .environment(\EnvironmentValues.colorScheme, ColorScheme.dark)
//        LayoutBehavior()
//            .previewDevice(PreviewDevice(rawValue: "iPhone X"))
//            .environment(\.sizeCategory, .accessibilityExtraExtraLarge)
//            .previewLayout(PreviewLayout.fixed(width: 896,height: 414))
            
    }
}
